<template>
<div>
    <div v-for="item in dataList">
        <input type="hidden" v-model="item.id" >
         角色名称：<input type="text" v-model="item.name" ><br/>
         备注:
        <el-input
                type="textarea"
                :rows="5"
                placeholder="请输入内容"
                v-model="item.remarks">
        </el-input>
         <input type="button" @click="upd()" value="修改">
    </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            msg:'我是修改页面',
            remarks: '',
            dataList:[]
        }
        
    },mounted(){
        var id = this.$route.params.id;
        console.log("-----"+id)
        var formData = new FormData();
        formData.append('id',id);
        var api="http://localhost:8089/admin/role/selectById";
        this.$http.post(api,formData).then(function(data){
            console.log(data);
        if(data.body.code=='10000'){
             alert(data.body.msg);
             this.dataList = data.body.tableData;
        }
        });
    },
    methods:{
        upd(){
            var id=this.dataList[0].id;
            var name=this.dataList[0].name;
            var remarks=this.dataList[0].remarks;
            var formDate =new FormData();
            formDate.append('id',id);
            formDate.append('name',name);
            formDate.append('remarks',remarks);
            var api='http://localhost:8089/admin/role/update';
            this.$http.post(api,formDate).then(function(date){
            if(date.body.code=='10000'){
               // alert(data.body.msg);
                window.location.href="http://localhost:8080/#/role";
            }
             alert(date.body.msg);
         })
           }
        }
    }
</script>